package com.chen.facemanager.util;

/**
 * @ClassName CodeMsg
 * @Description
 * @Author Mr-CHEN
 * @Date 2019/8/20 19:26
 * @Version V1.0
 **/

public class CodeMsg {

    private int code;
    private String msg;

    //通用的错误码
    public static CodeMsg ACCESS_LIMIT_REACHED= new CodeMsg(8888, "访问太频繁！");

    private CodeMsg( ) {
    }

    private CodeMsg( int code,String msg ) {
        this.code = code;
        this.msg = msg;
    }

    public int getCode() {
        return code;
    }
    public void setCode(int code) {
        this.code = code;
    }
    public String getMsg() {
        return msg;
    }
    public void setMsg(String msg) {
        this.msg = msg;
    }

    public CodeMsg fillArgs(Object... args) {
        int code = this.code;
        String message = String.format(this.msg, args);
        return new CodeMsg(code, message);
    }

    @Override
    public String toString() {
        return "CodeMsg [code=" + code + ", msg=" + msg + "]";
    }


}